import {createRouter, createWebHistory} from 'vue-router'
import layout from '../components/layout/layout.vue'

const router = createRouter({
    history: createWebHistory(import.meta.env.BASE_URL),
    routes: [
        {
            path: '/',
            name: 'app',
            redirect: '/page/console',
        },
        {
            path: '/page',
            name: 'page',
            component: layout,
            redirect: '/page/console',
            children: [
                {
                    path: 'console',
                    name: '控制台',
                    meta: {title: '控制台'},
                    component: () => import('@/views/console/index.vue')
                },
                {
                    path: 'config',
                    name: '网关配置',
                    meta: {title: '网关配置'},
                    component: () => import('@/views/gateway/config/index.vue')
                },
                {
                    path: 'history',
                    name: '发布历史',
                    meta: {title: '发布历史'},
                    component: () => import('@/views/gateway/history/index.vue')
                },
                {
                    path: 'ipList',
                    name: '黑白名单',
                    meta: {title: '黑白名单'},
                    component: () => import('@/views/gateway/ipList/index.vue')
                },
                {
                    path: 'ssl',
                    name: '证书',
                    meta: {title: '证书'},
                    component: () => import('@/views/gateway/ssl/index.vue')
                },
                {
                    path: 'accessLog',
                    name: '访问日志',
                    meta: {title: '访问日志'},
                    component: () => import('@/views/gateway/accessLog/index.vue')
                },
                {
                    path: 'action',
                    name: '操作日志',
                    meta: {title: '操作日志'},
                    component: () => import('@/views/action/index.vue')
                },
                {
                    path: 'file',
                    name: '文件',
                    meta: {title: '文件'},
                    component: () => import('@/views/host/file/index.vue')
                },
                {
                    path: 'shell',
                    name: '终端',
                    meta: {title: '终端'},
                    component: () => import('@/views/host/shell/index.vue')
                }
            ]
        },
        {
            path: '/login',
            name: '登录',
            meta: {title: '登录'},
            component: () => import('@/views/login/index.vue')
        },
        {
            path: '/:pathMatch(.*)*',
            name: 'NotFound404',
            redirect: '/page/console'
        },
    ]
})

export default router
